package com.itzgyw.example.config;

import com.itzgyw.cache.base.MetadataTrusteeship;
import com.itzgyw.example.entity.IdEntity;

/**
 * @Auther: Mr. Zeng
 * @Date: 2020/12/8 17:37
 * @Description: 暂无描述
 */
public class IdEntityMetadataTrusteeship implements MetadataTrusteeship<IdEntity> {
    @Override
    public Class getSupportClasses() {
        return IdEntity.class;
    }

    @Override
    public String getSupportClassUnique(IdEntity entity) {
        return Integer.toString(entity.getId());
    }

    @Override
    public Object[] getReloadParameters(String reloadBeanName, String reloadMethodName, String supportClassUnique) {
        if (reloadMethodName.equals("findById")) {
            return new Object[]{Integer.valueOf(supportClassUnique)};
        } else {
            String[] value = supportClassUnique.split("-");
            return new Object[]{Integer.valueOf(value[0]), Integer.valueOf(value[1])};
        }

    }
}
